Skip to content

Conversation

@cyyever
Copy link
Contributor

@cyyever cyyever commented Aug 13, 2025

Essential Elements of an Effective PR Description Checklist

This PR removes unnecessary CUDA sync in _process_image_input and _process_video_input of vllm/model_executor/models/qwen2_5_vl.py by utilising grid_thw_list.

Before the fix, the _process_image_input function of vllm/model_executor/models/qwen2_5_vl.py could take near 1/4 of the OwnTime as measured by py-spy, see:
image

After the fix, the bottlenecks have been moved to other places, and there are further fixes. However, this fix is quite simple that I want to submit first.
image

@cyyever cyyever requested a review from sighingnow as a code owner August 13, 2025 07:01
@mergify mergify bot added the qwen Related to Qwen models label Aug 13, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request aims to remove unnecessary CUDA synchronizations in qwen2_5_vl.py for performance improvement. The changes in _process_image_input and _process_video_input correctly identify a source of synchronization but introduce a correctness bug when handling empty inputs. My review provides critical feedback with suggestions to fix this bug while still achieving the desired performance gain.

@github-actions
Copy link

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can either: Add ready label to the PR or enable auto-merge.

🚀

Copy link
Member

@DarkLight1337 DarkLight1337 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, can you provide some profiling or benchmark results to show the effectiveness of this optimization?

@cyyever
Copy link
Contributor Author

cyyever commented Aug 13, 2025

@DarkLight1337 Added.

Signed-off-by: cyy <cyyever@outlook.com>
cyyever and others added 2 commits August 13, 2025 18:14
Co-authored-by: Cyrus Leung <cyrus.tl.leung@gmail.com>
Signed-off-by: Yuanyuan Chen <cyyever@outlook.com>
Signed-off-by: cyy <cyyever@outlook.com>
Copy link
Member

@DarkLight1337 DarkLight1337 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick response, LGTM!

@DarkLight1337 DarkLight1337 enabled auto-merge (squash) August 13, 2025 10:21
@github-actions github-actions bot added the ready ONLY add when PR is ready to merge/full CI is needed label Aug 13, 2025
@vllm-bot vllm-bot merged commit 6772bb0 into vllm-project:main Aug 13, 2025
41 of 47 checks passed
@cyyever cyyever deleted the qwen_fix branch August 15, 2025 13:03
diegocastanibm pushed a commit to diegocastanibm/vllm that referenced this pull request Aug 15, 2025
…-project#22792)

Signed-off-by: cyy <cyyever@outlook.com>
Signed-off-by: Yuanyuan Chen <cyyever@outlook.com>
Co-authored-by: Cyrus Leung <cyrus.tl.leung@gmail.com>
Signed-off-by: Diego-Castan <diego.castan@ibm.com>
yiliu30 pushed a commit to yiliu30/vllm-fork that referenced this pull request Aug 19, 2025
…-project#22792)

Signed-off-by: cyy <cyyever@outlook.com>
Signed-off-by: Yuanyuan Chen <cyyever@outlook.com>
Co-authored-by: Cyrus Leung <cyrus.tl.leung@gmail.com>
divakar-amd pushed a commit to divakar-amd/vllm_upstream that referenced this pull request Aug 20, 2025
…-project#22792)

Signed-off-by: cyy <cyyever@outlook.com>
Signed-off-by: Yuanyuan Chen <cyyever@outlook.com>
Co-authored-by: Cyrus Leung <cyrus.tl.leung@gmail.com>
epwalsh pushed a commit to epwalsh/vllm that referenced this pull request Aug 28, 2025
…-project#22792)

Signed-off-by: cyy <cyyever@outlook.com>
Signed-off-by: Yuanyuan Chen <cyyever@outlook.com>
Co-authored-by: Cyrus Leung <cyrus.tl.leung@gmail.com>
xiao-llm pushed a commit to xiao-llm/vllm that referenced this pull request Aug 28, 2025
…-project#22792)

Signed-off-by: cyy <cyyever@outlook.com>
Signed-off-by: Yuanyuan Chen <cyyever@outlook.com>
Co-authored-by: Cyrus Leung <cyrus.tl.leung@gmail.com>
Signed-off-by: Xiao Yu <xiao.yu@amd.com>
zhewenl pushed a commit to zhewenl/vllm that referenced this pull request Aug 28, 2025
…-project#22792)

Signed-off-by: cyy <cyyever@outlook.com>
Signed-off-by: Yuanyuan Chen <cyyever@outlook.com>
Co-authored-by: Cyrus Leung <cyrus.tl.leung@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

qwen Related to Qwen models ready ONLY add when PR is ready to merge/full CI is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants